package com.itany.corejava.day14;

import java.io.*;

public class TestInputStreamReader {


    public static void main(String[] args) {


        FileInputStream fis=null;
        InputStreamReader isr=null;

        OutputStreamWriter osw=null;

        try{

            fis=new FileInputStream("d:/a.txt");
            isr=new InputStreamReader(fis,"utf-8");

            osw=new OutputStreamWriter(new FileOutputStream("d:/b.txt"),"utf-8");

            System.out.println(isr.getEncoding());

            char[] c=new char[1000];

            int n;

            while((n=isr.read(c))!=-1){
                System.out.print(new String(c,0,n));
                osw.write(c,0,n);
            }


        }catch (Exception e){
            e.printStackTrace();
        }finally{
            if(isr!=null){
                try {
                    isr.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            if(fis!=null){
                try {
                    fis.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }

            if(osw!=null){
                try {
                    osw.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }


    }

}
